#pragma once
#ifndef _D3D_TEXTURE_
#define _D3D_TEXTURE_

#include <windows.h>
#include <d3dx9.h>
#include "interface_types.h"
#include "..\math\vector.h"
#include "..\common\types.h"
#include "..\common\arraylist.hpp"
#include "..\common\string.h"
#include "d3d_util.h"

class CD3D9Device; 

struct EE_EXPORT Texture : public IResource
{
protected:
	LPDIRECT3DBASETEXTURE9 m_pDataD3D; 
	D3DXIMAGE_INFO		textureInfo; 
public:
	virtual HRESULT	Create(const string &szFilename) = 0; 
	virtual HRESULT	Release(void) = 0; 
	virtual HRESULT	Reload(void) = 0; 
	virtual LPDIRECT3DBASETEXTURE9 DataD3D(); 

	Texture(CD3D9Device* const pDevice); 

}; 

struct EE_EXPORT D3DTexture2D : public Texture
{
	friend CD3D9Device; 
	HRESULT	Create(const string &szFilename); 
	HRESULT	Release(void); 
	HRESULT	Reload(void); 
	Vector2f GetDimensions();
	string GetType() const; 
private:
	D3DTexture2D(CD3D9Device* const pDevice); 
}; 

struct EE_EXPORT D3DAnimatedTexture2D : public Texture
{
	ArrayList<Texture*> frames;
	float m_FrameRate;
	unsigned int m_FrameCount;
	friend CD3D9Device; 
	HRESULT	Create(const string &szFilename); 
	HRESULT	Release(void); 
	HRESULT	Reload(void); 
	string GetType() const; 
	HRESULT CreateTextureFrames(const string *pFilenames, const int frameCount, const float frameRate = 1.0f);
	LPDIRECT3DBASETEXTURE9 DataD3D(); 
private:
	D3DAnimatedTexture2D(CD3D9Device* const pDevice); 
}; 

struct EE_EXPORT D3DTexture3D : public Texture
{ 
	friend CD3D9Device; 

	HRESULT	Create(const string &szFilename); 
	HRESULT	Release(void); 
	HRESULT	Reload(void); 
	string GetType() const; 

private:
	D3DTexture3D(CD3D9Device* const  pDevice); 
}; 

#endif